<?php
namespace app\index\controller;

use think\Controller;
use app\index\model\Arctype;
use app\index\model\Archive;

class Category extends Common
{
    public function _initialize(){
        parent::_initialize();
		$this->assign('CateList',GetCategory());
    }
    
    public function index()
    {
		$this->redirect('Category/news');
    }
	public function news(){
		$archiveModel = new Archive();
		$typeModel = new Arctype();
		$where['status'] = 1;
		$where['mod'] = 'addonarticle';
		if(input('id')){
			$where['typeid'] = ['eq',input('id')];
			$typeInfo = $typeModel->where(['id'=>input('id')])->find();
			$this->assign('webtitle',$typeInfo['webtitle'] ? $typeInfo['webtitle'].' - 好融艺' : $typeInfo['typename'].' - 好融艺' );
			$this->assign('keywords',$typeInfo['keywords']);
			$this->assign('description',$typeInfo['description']);
		}else{
			$this->assign('webtitle','新闻中心 - 好融艺');
		}
		$order = 'create_time desc,click desc';
		$dataList = $archiveModel->where($where)->order($order)->paginate(5);

		$this->assign('ur_here',input('id') ? typename(input('id')) : '新闻中心');
		$this->assign('dataList',$dataList);
		return $this->fetch();
	}
}
